# -*- coding: utf-8 -*-

from .base import BaseClient

try:
    from urllib.parse import urlencode
except ImportError:
    from urllib import urlencode

import json
import time

import requests


class Client(BaseClient):
    def __init__(self, client_id, client_secret, redirect_uri, token=None):
        # const define
        self.provider = 'google'
        self.authorization_url = 'https://accounts.google.com/o/oauth2/auth'
        self.grant_url = 'https://accounts.google.com/o/oauth2/token'
        self.api_url = 'https://www.googleapis.com/'
        self.response_type = 'code'
        self.grant_type = 'authorization_code'
        # init basic info
        self.client_id = client_id
        self.client_secret = client_secret
        self.redirect_uri = redirect_uri

        # client scope
        self.scope = {
            'basic': 'https://www.googleapis.com/auth/plus.me profile',
            'email': 'email',
            'birthday': '',
            'events': '',
            'photos': 'https://picasaweb.google.com/data/',
            'videos': 'http://gdata.youtube.com',
            'friends': 'https://www.google.com/m8/feeds, https://www.googleapis.com/auth/plus.login',
            'files': 'https://www.googleapis.com/auth/drive.readonly',
            'publish': '',
            'publish_files': 'https://www.googleapis.com/auth/drive',
            'share': '',
            'create_event': '',
            'offline_access': ''
        }

        # activate client directly if given token
        if token:
            self.set_token(token)
